import { ISearchConfig } from './module/search.module';
import { Component, Input, Output, OnChanges, OnInit } from '@angular/core';
let style = require('./search.component.scss');
/**
 * 
 * 
 * @export
 * @class SearchComponent
 * @implements {OnInit}
 */
@Component({
    selector: 'wit-search',
    templateUrl: 'search.component.html',
    styles: [style],
})
export class SearchComponent implements OnInit {
    /**
     * 当前输入的字符
     * 
     * @type {string}
     * @memberOf SearchComponent
     */
    @Input() inputVal: string;
    /**
     * 接口，传递相关配置
     * 
     * @type {ISearchConfig}
     * @memberOf SearchComponent
     */
    @Input() searchConfig:ISearchConfig;
    /**
     * Creates an instance of SearchComponent.
     * 
     * 
     * @memberOf SearchComponent
     */
    constructor() {
    
    }
    /**
     * 清除输入文本
     * 
     * 
     * @memberOf SearchComponent
     */
    handleClear() {
        this.inputVal = null;
        
        // if(this.searchConfig.clearValBak){
        //     this.searchConfig.clearValBak();
        // }
    }
    /**
     * 
     * 
     * 
     * @memberOf SearchComponent
     */
    ngOnInit(){
        this.inputVal  = this.searchConfig.initVal;
    }
    /**
     * 输入字符改变是执行事件
     * 
     * 
     * @memberOf SearchComponent
     */
    changeSearch(){
        this.searchConfig.filterSearchChange(this.inputVal);
    }
    /**
     * 点击搜索
     * 
     * 
     * @memberOf SearchComponent
     */
    search(){
        this.searchConfig.filterSearch(this.inputVal);
    }
}